package com.example.myapplication;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class HelloActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hello);



        AlertDialog alertDialog1 = new AlertDialog.Builder(this)
                .setTitle("Helloworld")//标题
                .setMessage("welcome to China ,HelloWorld!!!")//内容
                .setIcon(R.mipmap.ic_launcher)//图标
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {//添加"Yes"按钮
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Toast.makeText(HelloActivity.this, "这是确定按钮", Toast.LENGTH_SHORT).show();
                    }
                })

                .setNegativeButton("取消", new DialogInterface.OnClickListener() {//添加取消
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Toast.makeText(HelloActivity.this, "这是取消按钮", Toast.LENGTH_SHORT).show();
                    }
                })
                .setNeutralButton("普通按钮", new DialogInterface.OnClickListener() {//添加普通按钮
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Toast.makeText(HelloActivity.this, "这是普通按钮按钮", Toast.LENGTH_SHORT).show();
                    }
                })
                .create();
        alertDialog1.show();
    }



}